

#include "io_thread_group.h"
#include "../common/log.h"

namespace rocket {

IOThreadGroup::IOThreadGroup(int size) : m_size(size) {
    m_io_thread_groups.resize(size);
    for (int i = 0; i < size; i++) {
        m_io_thread_groups[i] = new IOThread();
    }
}

IOThreadGroup::~IOThreadGroup() {}

void IOThreadGroup::join() {
    for (int i = 0; i < m_size; i++) {
        m_io_thread_groups[i]->join();
    }
}

void IOThreadGroup::start() {
    for (int i = 0; i < m_size; i++) {
        m_io_thread_groups[i]->start();
    }
}

IOThread *IOThreadGroup::getIOThread() {
    m_index %= m_size;
    return m_io_thread_groups[m_index++];
}

} // namespace rocket
